package com.thor.palmmall.rest.order.converter;

import java.util.ArrayList;
import java.util.List;

import org.springframework.core.convert.converter.Converter;

import com.thor.palmmall.rest.order.AProductActivitie;
import com.thor.palmmall.spi.order.SProductActivitie;

public class AProductActivitieConverter implements Converter<List<SProductActivitie>,List<AProductActivitie>>{
	public static AProductActivitieConverter getInstance() {
		if (instance == null)
			instance = new AProductActivitieConverter();
		return instance;
	}

	private static AProductActivitieConverter instance;

	@Override
	public List<AProductActivitie> convert(List<SProductActivitie> sourceList) {
		if(sourceList == null || sourceList.size()==0){
			return null;
		}
		List<AProductActivitie> list = new ArrayList<AProductActivitie>();
		for (SProductActivitie source : sourceList) {
			AProductActivitie target = new AProductActivitie();
			target.setActivityId(source.getActivityId());
			target.setPromotionUuid(source.getPromotionUuid());
			target.setContract(source.getContract());
			target.setSerialNumber(source.getSerialNumber());
			target.setDiscountAmount(source.getDiscountAmount());
			target.setName(source.getName());
			list.add(target);
		}
		return list;
	}
}
